<?php
namespace app\home\controller;

use app\common\model\Feedback;

// 所有post的请求都在这里做
class Handler extends Base
{
    public function handlePost($act)
    {
        $post_data = input('post.');
        switch ($act) {
            case 'feedback':
                $this->createFeedback($post_data);
                break;

            case '...':
                break;

            default:
                $this->error('非法请求');
        }
        return null;
    }
    private function createFeedback($post_data)
    {
        $this->handleValidate($post_data, [
            'name|姓名' => 'require|token',
            'phone|电话' => 'require'
        ]);
        $res = Feedback::createItem($post_data);
        $res ? $this->success('已提交') : $this->error('提交失败');
    }
}